<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<script language=JavaScript>
<!--

function onClickSetCurrentPhase(theForm) {

  if (theForm.currentPhaseId.value == 0) {
    alert('<bean:message key="cs.error.phase.notselect"/>');     
    return false;
  }
  // set the hidden field of displayPhaseId to use the
  // newly selected current phase.
  theForm.displayPhaseId.value = theForm.currentPhaseId.value;
  theForm.submit();
}


function confirmDeletePhase()
{
   if (confirm("<bean:message key="cs.confirm.delete.phase"/>"))
   {
      return true;
   }
   else
   {
      return false;
   }
}

function onClickCloseMicrosite (theForm) {
  if (confirm('<bean:message key="cs.microsite.close.confirm"/>')) {
    theForm.submit();
  } else {
    return false;
  }   
}

function onClickAdvancePhase (theForm) {
  theForm.displayPhaseId.value = theForm.nextPhaseId.value;
  theForm.submit();
}

function onClickStartPhase (theForm) {
  theForm.submit();
}

// -->
</script>

<!-- Zone 5 starts here.  -->
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
    
    <!--start microsite logo and name here-->
    <div class="app_pageTitle">
      <%@ include file="/cs/microsite/micrositeNaviInfo.jsp" %>
    </div> 
    <!--end microsite logo and name here-->

    <!--start title bar here-->
    <div class="app_pageSubtitle">
      <!-- Phases index title -->
      <span class="left">
       <bean:message key="cs.phases.index"/>
      </span>
      <span class="right">
        <!-- Create new button -->      
        <html:form action="/cs/phaseNew.do">
          <bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>
          <html:submit styleClass="titleButton" property="createNewPhaseBtn">
          	<bean:message key="button.createNew"/>
          </html:submit>
        </html:form>
      </span>
    </div> 
    <!--end title bar here-->

<div class="blockWrap">
    <logic:equal name="phaseListView" property="inStartPhase" value="false">
      <logic:equal name="phaseListView" property="micrositeClosed" value="false">
        <div class="pageInstructions">
          <bean:message key="cs.phase.currentphase.note" />
        </div>
      </logic:equal>
    </logic:equal>
    <!-- button to advance current phase, or to close collaboration -->
    <div class="globalButtonWrap">
      <%-- if microsite is closed already, just show the status of 
           "Collaboration completed". No button is shown. --%>
      <logic:equal name="phaseListView" property="inStartPhase" value="true">
        <c:choose>
          <c:when test="${micrositeNaviInfoView.map.isMicrosite}">
            <bean:message key="cs.microsite.not.started"/>
          </c:when>
          <c:otherwise>
            <bean:message key="cs.collaboration.not.started"/>
          </c:otherwise>
        </c:choose>
      </logic:equal>
      <logic:equal name="phaseListView" property="micrositeClosed" value="true">
        <c:choose>
          <c:when test="${micrositeNaviInfoView.map.isMicrosite}">
            <bean:message key="cs.microsite.is.closed"/>
          </c:when>
          <c:otherwise>
            <bean:message key="cs.collaboration.is.closed"/>
          </c:otherwise>
        </c:choose>
      </logic:equal>
      <logic:notEqual name="phaseListView" property="micrositeClosed" value="true">
        <logic:equal name="phaseListView" property="inSetupPhase" value="true">
          <%-- show "advance to next phase" button when not in last phase
                                                  or uninitialized phase --%>
          <html:form action="/cs/phaseList.do">
            <bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>
            <html:hidden property="action" value="ADVANCE_PHASE" />   
            <input type="hidden" name="nextPhaseId" 
                   value='<bean:write name="phaseListView" property="nextPhaseId"/>'>
            <html:button styleClass="globalButton" property="advancePhaseBtn"
                         titleKey="cs.phase.currentphase.advance.button" 
                         onclick="onClickAdvancePhase(this.form)">
              <bean:message key="cs.phase.currentphase.advance.button"/>
            </html:button>
          </html:form>
        </logic:equal>
      </logic:notEqual>
    </div>
    
    <!--start main content area here-->
  
    <!-- List of phases (begin) -->
    <table class="dataTable" border="0" cellspacing="1" cellpadding="2" 
           summary="List of phases in current microsite" width="100%">
      <tr class="listHeader"> 
        <th id="Name" align="left"><bean:message key="cs.name"/></th>
        <th id="Description" align="left"><bean:message key="cs.description"/></th>
        <th id="Goal" align="left"><bean:message key="cs.goal"/></th>
        <th id="Action" align="left"><bean:message key="cs.actions"/></th>        
      </tr>
 
      <logic:iterate id="onePhase" name="phaseItems" indexId="index">
        <tr class='<%=index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>'> 
          <td headers="Name">
            <logic:equal name="onePhase" property="equalCurrentPhase" value="true">
              <b>**<bean:write name="onePhase" property="name"/></b>
            </logic:equal>
            <logic:notEqual name="onePhase" property="equalCurrentPhase" value="true">
              <bean:write name="onePhase" property="name"/>
            </logic:notEqual>            
          </td>    
          <td headers="Description">
            <bean:write name="onePhase" property="description"/>
          </td>
          <td headers="Goal">
            <bean:write name="onePhase" property="goal"/>
          </td>          
          <td headers="Action" nowrap align="left" >
            <%-- Display Edit and Delete button --%>          
            <html:link page="/cs/phaseEdit.do" name="onePhase" property="urlParams">
              <html:img page="/cs/images/action/icon_edit.gif" border="0" altKey="cs.image.alt.edit" styleClass="actionIcon"/>
            </html:link>
            <logic:equal name="onePhase" property="deletable" value="true">
              <html:link page="/cs/phaseDelete.do" name="onePhase" property="urlParams" onclick="return confirmDeletePhase();">
                <html:img page="/cs/images/action/icon_delete.gif" border="0" altKey="cs.image.alt.delete" styleClass="actionIcon"/>
              </html:link>            
            </logic:equal>
            &nbsp;
          </td>
        </tr>
      </logic:iterate>
    </table>
    <!-- List of phases (end) -->    

    <!-- Drop down to select current phase for microsite (begin) -->
    <logic:equal name="phaseListView" property="inStartPhase" value="false">
    <logic:equal name="phaseListView" property="micrositeClosed" value="false">
    <div class="pageButtonWrap">
      <html:form action="/cs/phaseList.do" method="post">
        <bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>
        <html:hidden property="action" value="RESET_PHASE" />        
          <b><bean:message key="cs.phase.currentphase.reset"/>:</b>
          <html:select name="csPhaseListForm" property="currentPhaseId" size="1">
            <option value=0><bean:message key="cs.phase.currentphase.default"/></option>
            <html:optionsCollection name="phasesDropDownView" property="phaseNamesAndIds"/>
          </html:select>&nbsp;
          <html:button styleClass="globalButton" property="setCurrentPhaseBtn" 
                       titleKey="button.set" onclick="onClickSetCurrentPhase(this.form)">
            <bean:message key="button.set"/>
          </html:button>
      </html:form>
    </div>
    </logic:equal>
    </logic:equal>
    <!-- Drop down to select current phase for microsite (end) -->

 </div>
    <!--end main content area here-->
  
    <td>
  </tr>
</table>

